package com.tencent.qcloud.tuikit.tuichat.classicui.widget.message.viewholder;

import android.view.View;
import android.widget.LinearLayout;

import com.tencent.qcloud.tuikit.timcommon.bean.TUIMessageBean;
import com.tencent.qcloud.tuikit.timcommon.classicui.widget.message.MessageContentHolder;
import com.tencent.qcloud.tuikit.tuichat.R;
import com.tencent.qcloud.tuikit.tuichat.bean.CustomRedPackageMessage;
import com.tencent.qcloud.tuikit.tuichat.bean.message.CustomRedPackageMessageBean;
import com.tencent.qcloud.tuikit.tuichat.callback.ChatAppModule;

import java.util.ArrayList;
import java.util.List;

public class CustomRedPackageMessageHolder extends MessageContentHolder {
    private View rootView;
    private LinearLayout ll_bg;

    public CustomRedPackageMessageHolder(View itemView) {
        super(itemView);
        ll_bg = itemView.findViewById(R.id.ll_bg);
        rootView = itemView.findViewById(R.id.rootView);
    }

    public static final String TAG = CustomRedPackageMessageHolder.class.getSimpleName();

    @Override
    public int getVariableLayout() {
        return R.layout.custom_red_package_message_layout;
    }

    @Override
    public void layoutVariableViews(TUIMessageBean msg, int position) {
        boolean isGroup = false;
        String pkgID = "";
        String title = "";
        String content = "";
        double money = 0;
        int num = 0;
        int type = 0;
        String sendUName = "";
        String endTime = "";
        List<CustomRedPackageMessage.ReceiveBean> receivedBeanList = new ArrayList<>();
        if (msg instanceof CustomRedPackageMessageBean) {
            pkgID = ((CustomRedPackageMessageBean) msg).getPkgID();
            title = ((CustomRedPackageMessageBean) msg).getText();
            isGroup = ((CustomRedPackageMessageBean) msg).getIsGroup();
            money = ((CustomRedPackageMessageBean) msg).getMoney();
            sendUName = ((CustomRedPackageMessageBean) msg).getSendUName();
        }

        msgContentFrame.setClickable(true);
        String finalPkgID = pkgID;
        setMessageBubbleZeroPadding();
        msgContentFrame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ChatAppModule.init().performGetRedPackageActionChat(rootView.getContext(), (CustomRedPackageMessageBean) msg);
            }
        });
    }
}
